package org.snail.department.service.push;

import org.apache.log4j.Logger;
import org.snail.activemq.PushService;
import org.snail.department.service.message.DeptInfoMessageCreator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;

@Service
@Scope("prototype")
public class DeptInfoPushService implements PushService{

    private static final Logger LOGGER = Logger.getLogger(DeptInfoPushService.class);

    @Autowired
    private JmsTemplate jmsTemplate;
    @Autowired
    @Qualifier("deptInfoQueue")
    private Destination destination;

    /**
     * @param sendObject  推送的相关内容
     */
    public void push(Object sendObject) {

        DeptInfoMessageCreator messageCreator = new DeptInfoMessageCreator();
        //创建消息执行者
        messageCreator.setSendObject(sendObject);

        //推送消息到队列
        jmsTemplate.send(destination, messageCreator);

    }

}
